<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>Document</title>
    </head>
    <body>
        <h1>箭头函数</h1>
        <p>来源:<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions">https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions</a></p>
        <h2>更短的函数</h2>
        <p>由于 this 已经在词法层面完成了绑定，通过 call() 或 apply() 方法调用一个函数时，只是传入了参数而已，对 this 并没有什么影响：</p>
        <script>
            var materials = [
              'Hydrogen',
              'Helium',
              'Lithium',
              'Beryllium'
            ];

            var v1=materials.map(function(material) { 
              return material.length; 
            }); // [8, 6, 7, 9]

            var v2=materials.map((material) => {
              return material.length;
            }); // [8, 6, 7, 9]

            var v3=materials.map(material => material.length); // [8, 6, 7, 9]
            console.log('v1='+v1+';v2='+v2+';v3='+v3);
        </script>
    </body>
</html>